package com.dgut.adminmanager.service;

import com.dgut.adminmanager.dao.AdministratorDao;
import com.dgut.adminmanager.entity.Administrator;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Optional;

@Service("cwd")
public class AdminServiceImp implements AdminService {

    @Autowired
    AdministratorDao administratorDao;

    public AdminServiceImp() {
        super();
    }

    @Override
    public Optional<Administrator> findAdministratorById(Integer id) {
        return administratorDao.findById(id);
    }

    @Override
    public List<Administrator> findAllAdministrator() {
        return administratorDao.findAll();
    }

    @Override
    public Administrator findAdministratorByAccount(String account) {
        return administratorDao.findAdministratorByAccount(account);
    }

    @Override
    public void deleteAdministratorById(Integer id) {
        administratorDao.deleteById(id);
    }

    @Override
    public Administrator updateAdministrator(Administrator administrator) {
        return administratorDao.save(administrator);
    }

    @Override
    public Administrator addAdministrator(Administrator administrator) {
        return administratorDao.save(administrator);
    }

}
